package mspbots.teams.client.oauth;

import lombok.Data;
import org.springframework.validation.annotation.Validated;

import javax.validation.constraints.Min;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.io.Serializable;

/**
 * data.connector.teams.core.oauth.TokenState
 *
 * @author Alex bob(https://github.com/vnobo)
 * @date Created by 2020/4/15
 */
@Data
@Validated
public class TokenState implements Serializable {

    @Min(1)
    @NotNull(message = "Params [tenantId] can not be empty.")
    private Long tenantId;

    private TokenType tokenType;

    @NotBlank(message = "Params [accessToken] can not be empty.")
    private String accessToken;

    public TokenState(Long tenantId, TokenType tokenType, String accessToken) {
        this.tenantId = tenantId;
        this.tokenType = tokenType;
        this.accessToken = accessToken;
    }

    public static TokenState withDefault(Long tenantId) {
        return new TokenState(tenantId, TokenType.admin, null);
    }

    public Long getTenantId() {
        return tenantId;
    }

    public void setTenantId(Long tenantId) {
        this.tenantId = tenantId;
    }

    public TokenType getTokenType() {
        return tokenType;
    }

    public TokenState setTokenType(TokenType tokenType) {
        this.tokenType = tokenType;
        return this;
    }

    public String getAccessToken() {
        return accessToken;
    }

    public TokenState setAccessToken(String accessToken) {
        this.accessToken = accessToken;
        return this;
    }

    public enum TokenType {
        user, admin, loginToken
    }
}


